<?php
/**
 * Created by PhpStorm.
 * User: Acer
 * Date: 2022/7/23
 * Time: 16:50
 */

namespace app\admin\service;


use app\crontab\models\CardCensusModels;
use app\crontab\models\UserCensusModels;

class HomeService{
    // 获取用户统计
    public function s_statistics_user($data){
        $UserCensusModels = new UserCensusModels();
        $list = $UserCensusModels
            ->whereTime('census_time','between',[ $data['start_time'], $data['end_time'] ])
            ->field("DATE_FORMAT(census_time,'%Y-%m-%d') as census_time,total_number,add_number,attestation_number,add_attestation_number")
            ->order("census_time")
            ->select();
        $list = obj_to_arr($list);
        return $list;
    }

    // 首页卡片统计
    public function s_statistics_card($data){
        $CardCensusModels = new CardCensusModels();
        $list = $CardCensusModels
            ->whereTime('census_time','between',[ $data['start_time'], $data['end_time'] ])
            ->field("DATE_FORMAT(census_time,'%Y-%m-%d') as census_time,add_number,active_number,active_family_number,active_personal_number,active_qmx_number,active_my_number,day_active_number,day_active_family_number,day_active_personal_number,day_active_qmx_number,day_active_my_number,total_number")
            ->order('census_time')
            ->select();
        $list = obj_to_arr($list);
        return $list;
    }
}